package com.homework.wokr05;

public class Demo2 {
    public static void main(String[] args) {
        user2 user2 = new user2(1,"小红");
        user2 user22 = new user2(1,"小红");
        System.out.println(user2.equals(user22));

    }
}
class user2{
    private int id;
    private String name;
    public int getId() {
        return id;
    }
    public void setId(int id) {
        this.id = id;
    }
    public user2(int id, String name) {
        this.id = id;
        this.name = name;
    }
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    public user2() {
    }
    @Override
    public boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }
        if (obj instanceof user2) {
            user2 uu = (user2)obj;
            return this.id==uu.getId() && this.name.equals(uu.getName());
        }
        return false;
    }
}
